package com.ar.network;

import java.util.ArrayList;

import org.json.JSONObject;

import com.exartisan.bean.Data;
import com.loopj.android.http.RequestParams;

public class ParametersBuilder {

	public static RequestParams BuildGetQuizsParams(String categoryId, String diffId){
		RequestParams params = new RequestParams();
		params.put(NetworkUtility.REST_CATEGORY_ID, categoryId);
		params.put(NetworkUtility.REST_DIFFICULT_ID, diffId);
		return params;
	}
	
	public static RequestParams BuildLoginParams(String email, String passwords, String app_id){
		RequestParams params = new RequestParams();
		params.put(NetworkUtility.APP_ID, app_id);
		params.put(NetworkUtility.EMAIL, email);
		params.put(NetworkUtility.PASSWORDS, passwords);
		return params;
	}
	
	public static RequestParams BuildLoginFbParams(String email, String app_id){
		RequestParams params = new RequestParams();
		params.put(NetworkUtility.EMAIL, email);
		params.put(NetworkUtility.APP_ID, app_id);
		return params;
	}
	
	public static RequestParams BuildRegisterParams(String passwords, String name, String phone, String birthday, String email, String address, String chidoan){
		RequestParams params = new RequestParams();
		params.put(NetworkUtility.PASSWORDS, passwords);
		params.put(NetworkUtility.NAME, name);
		params.put(NetworkUtility.PHONE, phone);
		params.put(NetworkUtility.BIRTHDAY, birthday);
		params.put(NetworkUtility.EMAIL, email);
		params.put(NetworkUtility.ADDRESS, address);
		params.put(NetworkUtility.CHIDOAN, chidoan);
		return params;
	}
	
	public static RequestParams BuildUpdateInfoParams(String name, String phone, String birthday, String address, String chidoan){
		RequestParams params = new RequestParams();
		params.put(NetworkUtility.NAME, name);
		params.put(NetworkUtility.PHONE, phone);
		params.put(NetworkUtility.BIRTHDAY, birthday);
		params.put(NetworkUtility.ADDRESS, address);
		params.put(NetworkUtility.CHIDOAN, chidoan);
		return params;
	}
	
	public static RequestParams BuildSaveParams(String email, String contest_id, ArrayList<Data> user_data){
		RequestParams params = new RequestParams();
		JSONObject data = new JSONObject();
		for (Data d : user_data) {
			data.put(NetworkUtility.QUESTION_ID, d.getQuestionID());
			data.put(NetworkUtility.ANSWER, d.getUserAnswer());
		}
		params.put(NetworkUtility.EMAIL, email);
		params.put(NetworkUtility.CONTEST_ID, contest_id);
		params.put(NetworkUtility.UPLOAD_DATA, data.toString());
		return params;
	}
	
	public static RequestParams BuildSubmitParams(String email, String contest_id, ArrayList<Data> user_data){
		RequestParams params = new RequestParams();
		JSONObject data = new JSONObject();
		for (Data d : user_data) {
			data.put(NetworkUtility.QUESTION_ID, d.getQuestionID());
			data.put(NetworkUtility.ANSWER, d.getUserAnswer());
		}
		params.put(NetworkUtility.EMAIL, email);
		params.put(NetworkUtility.CONTEST_ID, contest_id);
		params.put(NetworkUtility.UPLOAD_DATA, data.toString());
		return params;
	}
	
}
